package com.ushio.gougouwangguo.controller;

import com.ushio.commonmodule.pojo.result.Result;
import com.ushio.gougouwangguo.entity.qo.ForestExplorationQo;
import com.ushio.gougouwangguo.entity.qo.ResourceListQo;
import com.ushio.gougouwangguo.entity.qo.ResourceSaveQo;
import com.ushio.gougouwangguo.entity.vo.ResourceVO;
import com.ushio.gougouwangguo.service.ResourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/resource")
@Tag(name = "Resources API", description = "资源")
public class ResourceController {

    @Autowired
    ResourceService resourceService;
    @GetMapping
    @Operation(summary = "查询当前用户所有资源",description = "查询当前用户所有资源")
    private Result<ResourceVO> getResource(ResourceListQo resourceListQo){
        try{

            ResourceVO resourceVO = resourceService.resourceListQo(resourceListQo);

            return Result.success(resourceVO);
        }catch (Exception e){
            e.printStackTrace();
          return   Result.fail(e.getMessage());
        }
    }

    @PostMapping("/save")
    @Operation(summary = "保存资源",description = "保存资源")
    private Result<ResourceVO> saveResource(@RequestBody ResourceSaveQo resourceListQo){
        try{

             resourceService.saveResource(resourceListQo);
            return Result.success();
        }catch (Exception e){
            e.printStackTrace();
            return Result.fail(e.getMessage());
        }
    }

}
